# Create/Configure Internal NAT
$Name = "InternalNAT"
$IPAddress = 192.168.0.1
$PrefixLength = 24
$ifIndex = (Get-NetAdapter | Where-Object {$_.Name -like "*InternalNat*" }).ifIndex

New-VMSwitch -Name $Name -SwitchType Internal
New-NetIPAddress -IPAddress $IPAddress -PrefixLength $PrefixLength -InterfaceIndex $ifIndex
New-NetNat -Name $Name -InternalIPInterfaceAddressPrefix 192.168.0.0/$PrefixLength

# Install/Configure DHCP Server on Host
$ScopeName = "Guest Scope"
$ScopeID = 192.168.0.0
$DefaultGateway = 192.168.0.1
$StartRange = 192.168.0.100
$EndRange = 192.168.0.2009
$ExclusionStart = 192.168.0.1
$ExclusionEnd = 192.168.0.9
$SubnetMask = 255.255.255.0
$State = "Active"

Import-Module DHCPServer
Install-WindowsFeature -Name DHCP -IncludeManagementTools 
netsh dhcp add securitygroups
Restart-Service dhcpserver

Add-DHCPServerv4Scope -Name $ScopeName 
  -StartRange $StartRange 
  -EndRange $EndRange 
  -SubnetMask $SubnetMask
  -State $State
  
 Add-DHCPServerv4ExclusionRange -ScopeID $ScopeID -StartRange $ExclusionStart -EndRange $ExclusionEnd
 Set-DHCPServerv4OptionValue -OptionID 3 -Value $DefaultGateway -ScopeID $ScopeID 
 
# Turn Off Server Manager DHCP Post-Installation Notifications
Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 
  –Name ConfigurationState 
  –Value 2
